package com.hfjava.practice01;

import java.util.Scanner;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: com.hfjava.practice01
 * @ClassName: Email
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/19 16:42
 * @Copyright 大牛版板所有
 */
public class Email {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入一串邮箱字符串：");
        String email = input.next();
        int index1 = email.indexOf('@');
        int index2 = email.indexOf('.');
        if (index1 != -1 && index2 != -1){
            if(index2 - index1 >1 && index1>0 &&index2<email.length()-2){
                System.out.println("邮箱格式正确！");
            }
            else {
                System.out.println("邮箱格式错误，邮箱中'@'和'.'位置不对！");
            }
        }
        else {
            System.out.println("邮箱格式错误，邮箱中没有'@'和'.'！！");
        }
    }
}
